package com.ruoyi.material.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.material.domain.VimsTask;
import com.ruoyi.material.domain.vo.VimsTaskVo;
import com.ruoyi.material.rpc.IVIMSTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【VIMS截图管理】Controller
 * 
 * @author ruoyi
 * @date 2021-07-29
 */
@RestController
@RequestMapping("/vims/task")
public class VimsTaskController extends BaseController
{
   @Autowired
   private  IVIMSTaskService vimsTaskService;


    /**
     * 查询【VIMS截图管理】列表
     */
    @PreAuthorize("@ss.hasPermi('vims:task:list')")
    @RequestMapping(value = "list",method = RequestMethod.GET)
    public String list(VimsTaskVo vimsTask) throws Exception {
        logger.info("list() === {}",vimsTask);
        return vimsTaskService.selectVimsTaskList(vimsTask);
    }

    /**
     * 导出【VIMS截图管理】列表
     */
    @PreAuthorize("@ss.hasPermi('vims:task:export')")
    @Log(title = "【VIMS截图管理】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VimsTask vimsTask)
    {
        List<VimsTask> list = null;
        ExcelUtil<VimsTask> util = new ExcelUtil<VimsTask>(VimsTask.class);
        return util.exportExcel(list, "【VIMS截图管理】数据");
    }

    /**
     * 获取【VIMS截图管理】详细信息
     */
    @PreAuthorize("@ss.hasPermi('vims:task:query')")
    @GetMapping(value = "/{schedulename}")
    public AjaxResult getInfo(@PathVariable("schedulename") String schedulename)
    {
        return AjaxResult.success(null);
    }


    /**
     * 修改【VIMS截图管理】
     */
    @PreAuthorize("@ss.hasPermi('vims:task:edit')")
    @Log(title = "【VIMS截图管理】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VimsTask vimsTask)
    {
        return null;
    }




    @RequestMapping(value = "/getChannelTree")
    public String getChannelTree(){
      return vimsTaskService.getChannelTree();
    }


    @RequestMapping(value = "/getPresetPoints/{channelCodes}", method =  RequestMethod.GET)
    public String getPresetPoints( @PathVariable List<String> channelCodes){
        logger.info("接受参数 === {}" ,channelCodes) ;
        return  vimsTaskService.getPresetPoint(channelCodes);
    }

    /**
     * 新增【VIMS截图管理】
     */
    @PreAuthorize("@ss.hasPermi('vims:task:add')")
    @Log(title = "【VIMS截图管理】", businessType = BusinessType.INSERT)
    @PostMapping
    public String add(@RequestBody VimsTaskVo vimsTask)
    {
        logger.info("{}=== add()==={}",this.getClass().getName(),vimsTask);

        return vimsTaskService.insertVimsTask(vimsTask);
    }

    /**
     * 删除【VIMS截图管理】
     */
    @PreAuthorize("@ss.hasPermi('vims:task:remove')")
    @Log(title = "【VIMS截图管理】", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{ids}")
    public String remove(@PathVariable String[] ids)
    {
        logger.info("=== params[{}]===",ids);
        return vimsTaskService.deleteVimsTaskByIds(ids);
    }



    /**
     * 任务的启动停止
     */
    @PreAuthorize("@ss.hasPermi('vims:task:stop')")
    @Log(title = "【VIMS截图管理】", businessType = BusinessType.DELETE)
    @GetMapping("/stop/{id}")
    public String stopTask(@PathVariable String id){

        return  vimsTaskService.stopVimsTaskByIds(id);
    }
}
